﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BMManage
{
    public partial class FormAddArea : Form
    {
        public FormAddArea()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BMWebService.BMWebService srv=new BMWebService.BMWebService();
            if (this.comboBox1.Text.Trim()=="")
            { 
                MessageBox.Show("名称不能为空");
                return;
            }
            string home = "1";
            if (checkBox1.AutoCheck)
            {
                home = "2";
            }
            var data = srv.AddAreaName(this.comboBox1.Text.Trim(), home);

            foreach (BMWebService.DataSetDB.AREASRow item in data)
            {
                if (item.AREANAME == this.comboBox1.Text.Trim())
                {
                    MessageBox.Show("添加成功");
                    return;
                }
            }
            MessageBox.Show("添加失败");
        }

        private void FormAddArea_Load(object sender, EventArgs e)
        {
            BMWebService.BMWebService srv = new BMWebService.BMWebService();
            var data = srv.AddAreaName("苏州","1");
            foreach (BMWebService.DataSetDB.AREASRow item in data)
            {
                this.comboBox1.Items.Add(item.AREANAME);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            BMWebService.BMWebService srv = new BMWebService.BMWebService();
            var data = srv.DelAddAreaName(this.comboBox1.Text.Trim());
            this.comboBox1.Items.Clear();
            foreach (BMWebService.DataSetDB.AREASRow item in data)
            {
                this.comboBox1.Items.Add(item.AREANAME);

            }
            this.comboBox1.Text = "";
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}
